package com.example.androidmaze;

//import com.example.androidmaze.Maze;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;

public class TitleActivity extends Activity implements OnSeekBarChangeListener {
	
////	Maze maze;
//	public TitleActivity() {
//		super() ;
//		System.out.println("MazeApplication: maze will be generated with a randomized algorithm.");
////		maze = new Maze() ;
////		maze.init() ;
//	}
	
	private static final String TAG = "TitleActivity";
	
	SeekBar seekDifficulty;
	Spinner spinnerGeneration;
	Spinner spinnerOperation;
	Spinner spinnerLoad;
	private int difficulty;
	sampleDraw sampleDraw;
	FirstPersonDrawer drawer;
	
	MazePanel mazeView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		sampleDraw = new sampleDraw(this);
//		sampleDraw.setBackgroundColor(Color.WHITE);
//		setContentView(sampleDraw);
		
//		mazeView = new MazePanel(this);
//		setContentView(mazeView);
		
//		drawer = new FirstPersonDrawer2(this);
//		drawer.setBackgroundColor(Color.WHITE);
//		setContentView(drawer);
		
		setContentView(R.layout.activity_title);
		
		seekDifficulty = (SeekBar)findViewById(R.id.difficultySeek);
		seekDifficulty.setOnSeekBarChangeListener(this);
		spinnerGeneration = (Spinner)findViewById(R.id.spinnerGeneration);
		spinnerOperation = (Spinner)findViewById(R.id.spinnerOperation);
		spinnerLoad = (Spinner)findViewById(R.id.spinnerLoad);
		
		Button btnStart = (Button)findViewById(R.id.buttonStart);
		
		btnStart.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String strGeneration = spinnerGeneration.getSelectedItem().toString();
				Log.v(TAG, "Generation algorithm is " + strGeneration);
				String strOperation = spinnerOperation.getSelectedItem().toString();
				Log.v(TAG, "Operation method is " + strOperation);
				String strLoad = spinnerLoad.getSelectedItem().toString();
				Log.v(TAG, "Choice to Load new maze is " + strLoad);
				Log.v(TAG, "START clicked");
				toGenerating(v);
			}
		});
		
	}

	public void toGenerating(View view) {
		String strGeneration = spinnerGeneration.getSelectedItem().toString();
		String strOperation = spinnerOperation.getSelectedItem().toString();
		String strLoad = spinnerLoad.getSelectedItem().toString();
		
		Intent intent = new Intent(this, GeneratingActivity.class);
		intent.putExtra("Generation", strGeneration);
		intent.putExtra("Operation", strOperation);
		intent.putExtra("Load", strLoad);
		intent.putExtra("Difficulty", difficulty);
		Log.v(TAG, "To activity GeneratingActivity");
		startActivity(intent);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.title, menu);
		return true;
	}

	@Override
	public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
		difficulty = seekDifficulty.getProgress();
		Log.v(TAG, "difficulty changed to " + difficulty);
		
	}

	@Override
	public void onStartTrackingTouch(SeekBar arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onStopTrackingTouch(SeekBar arg0) {
		// TODO Auto-generated method stub
		
	}

}
